<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../node_modules/vue/dist/vue.js"></script>
    <style>
        .v-enter,.v-leave-to{
            opacity: 0;
        }
        .v-enter-active,.v-leave-active{
            transition:opacity 1s;
        }

    </style>
</head>
<body>
    <div id="root">
        <!-- 
            怎么实现两个元素互相的进场出场动画
            使用key值来区分两者
            mode是设置元素动画类型
            属性有in-out,out-in
            接下来是动态组建的过渡动画效果
            直接控制:is里的组件名称就行
        -->
        <transition mode="out-in">
            <!-- <div v-if="show"key="hello">hello world</div>
            <div v-else key="bye">bye World</div> -->
            <component :is="show"></component>
        </transition>
        
        <button @click="handleClick">切换</button>
    </div>

    <script>
Vue.component('child',{
    template:`
              <div>child</div>
             `
    })
    Vue.component('child-one',{
    template:`
              <div>child-one</div>
             `
    })

        var vm  = new Vue({
            el:'#root',
            data:{
                show:'child'
            },
            methods:{
                handleClick(){
                    this.show = this.show === 'child'?'child-one':'child'
                }
            }
        })
    </script>
</body>
</html>